<h1>IT Department Primer</h1>
<b>Webhosting Basics</b>
<br>
<br><a href="../index.html">Back to Home</a>
<br>
<br><b>Web hosting basics</b>
<br>
<br>The Quirino PGO IT Department uses LAMPP or WAMP. These two are basically the same thing. Except that LAMPP works in linux and macintosh, while Wamp works in windows.
<br>
<br>LAMP stands for Linux, Apache, MySql, PHP / Perl. 
<br>WAMP stands for Windows, Apache, MySql and PHP.
<br>
<br>Lamp/Wamp are software tools that are commonly used together, to create programs that people with internet access (or local network connection) can access through a browser. They are so often used together that eventually, they were put together into one package.
<br>
<br>Apache is a web server. A web server is a program that stores web pages until somebody asks for them. It responds to a request from a browser (Internet Explorer, Mozilla Firefox, etc.), and then sends the pages through the network to the browser. 
<br>
<br>Mysql is a database server. This is a program that stores data in the form of tables. It accepts and stores data, and gives it back on request. The users ideally have no idea of the existence of Mysql, except when errors occur.  
<br>
<br>PHP is a programming language. You can write programs using this language. You can put PHP programs within web pages. When the web page is served, the program runs. Using the PHP program, you can read data from the Mysql database and display it on the webpage; or you could accept data entered in textboxes and save them into the database.
<br>
<br>Symfony is a web development platform. It auto-generates many of the PHP files and other files needed to create a standard CRUD (create-read-update-delete) program. It also makes the necessary connections to Mysql so you don't have to. You just need to tell it what columns the tables in the database have, then make small changes to the generated files to create your program. 
<br>
<br>A CRUD program is a program that can add data to a table, display the table, allow you to edit a row, or delete a row. 
<br>
<br><b>Your first very simple web program</b>
<br>
<br>Do the following steps to create your first web program.
<br>
<br>Create a file named hello.php. Open it in a text editor and paste the following code:
<br>
<br>&lt;?php
<br>echo "Hello World! ";
<br>echo "I am ";
<br>echo 10+20;
<br>echo " years old";
<br>?&gt;
<br>
<br>This is equivalent to writing "Hello World! I am 30 years old" into an HTML file. In fact this is exactly what the program does. Except that using PHP, you can extend the program to accept your name in a textbox, read your birthday from a database and tell you how old you are.
</ul>
<br>
<br>The web program needs a web server to run. If you already have Apache installed into your computer, just copy your file into Apache's "www" folder, then open a browser and type "http://localhost/hello.php". If not, you'll have to download and install Wamp on a windows machine, or Apache or Lampp in a linux machine. <a href="">Click here for the tutorial on installing LAMPP on Linux.</a> Do this only if you have the root password. Or if you prefer, install Wamp on Windows. It's a lot easier.
<br>
<br>Find a windows machine with an internet connection. Download a copy of the Wamp installer from www.wampserver.com, or <a href=/install/WampServer2.0f.exe>here (16 mb)</a>. Run the program and follow directions. Please read and understand the user agreement. If you're using Windows Vista, it will ask if you want to unblock the program. Choose "Yes, I've used this program before" (or whatever is written on the yes button).
<br>
<br>If you install it properly, and choose to making it run immediately after installation (it's a checkbox on the final page), you should see a small white semicircle that looks like a speedometer beside your Windows system clock, at the end of the taskbar (lower right of your windows screen). It should be filled with white, meaning all systems (apache, mysql and php) are working properly. 
<br>
<br>Go to Wamp's www folder (usually c:\wamp\www unless you specified a different location) and paste your hello.php file there. Then open your internet explorer or mozilla firefox, and then type http://localhost/hello.php there.
<br>
<br>You should see a "Hello World!" on the screen. Congratulations, you've just run your first web program.
<br>
<br><img src="helloworld.jpg">
<br>
<br><b>A taste of MySql and PHPMyAdmin</b>
<br>
<br>After you've installed Wamp in windows, you should be able to view the Mysql databases and tables, by using the PHPMyAdmin program included in Wamp. Just left-click the speedometer and select PHPMyAdmin, or type localhost/phpmyadmin in your browser (this doesn't always work).
<br>
<br>You should see something similar to the following:
<br>
<br><img src="phpmyadmin.jpg">
<br>
<br>
<br><b>Your first database</b>
<br>
<br>Create a database by typing a name in the "Create new database" box, like "sampledb", and pressing enter. It will now create the sampledb database, and ask you to create a table. 
<br>
<br><img src="phpmyadmincreatedb.jpg">
<br>
<br>Write a name, like "phonebook", put 3 in the "number of fields" box, and press enter. 
<br>
<br><img src="phpmyadmincreatetable.jpg">
<br>
<br>Fill in the field, type and length/values boxes with the information as displayed above, and press enter.
<br>
<br><img src="phpmyadmincreatedtable.jpg">
<br>
<br>You will have created your first table! Now you can add records by clicking on the insert tab. (It's near the top center of the screen) 
<br>
<br><img src="phpmyadmininsert.jpg">
<br>
<br>Enter your name, address and phone number like I did. Then press enter.
<br>
<br><img src="phpmyadmininserted.jpg">
<br>
<br>Notice that there's this line of text in the textbox:
<br>
<br>INSERT INTO `sampledb`.`phonebook` (`name`, `address`, `phoneno`) VALUES ('J Tomas', 'CFFQI, Cabarroguis, Quirino', '0939-468-0515');
<br>
<br>This is an sql statement, or a command that mysql accepts. There are sql commands for everything mysql does, from creating databases and tables to filling them with data, and searching for specific data. Like for example "all records with name starting with 'J'". In fact, everything we just did, from creating table sampledb, creating table phonebook, and creating the first phonebook entry, can be done with mysql statements. 
<br>
<br>Finally to see and be able to appreciate what we just did, click "browse" (clicking the table's name on the left side does the same thing.)
<br>
<br><img src="phpmyadminbrowse.jpg">
<br>
<br>Now you finally see the table itself, with one record. Imagine this table filled with hundreds of your contacts, and you are able to get the phone number of anybody just by clicking "search" and entering the following information:
<br>
<br><img src="phpmyadminsearch.jpg">
<br>
<br>This means that you're looking for somebody whose name starts with J. If instead you entered %Tomas, this means you're looking for somebody whose name ends with Tomas. Entering %Tom% will show you the data of everybody whose name contains the letters Tom anywhere in the name. You can also search for everybody you know living in Quirino, and call them one by one to get together for a party or something. 
<br>
<br><img src="phpmyadminsearch2.jpg">
<br>
<br>
<br><b>Accessing Mysql with PHP</b>
<br>
<br>

